package com.fl.rabbitmq.rabbitmqconsumer.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMqConfiguration {
    //创建交换机
    @Bean
    public FanoutExchange fanoutExchange(){
        return new FanoutExchange("fanout_order_echange",true,false);
    }
    //创建队列
    @Bean
    public Queue smsqueue(){
        return new Queue("smsqueue.fanout.queue",true);
    }

    @Bean
    public Queue Emailqueue(){
        return new Queue("Emailqueue.fanout.queue",true);
    }

    @Bean
    public Queue duanxinqueue(){
        return new Queue("duanxinqueue.fanout.queue",true);
    }
    //队列绑定交换机
    @Bean
    public Binding smsBinding(){
        return BindingBuilder.bind(smsqueue()).to(fanoutExchange());
    }
    @Bean
    public Binding EmailBinding(){
        return BindingBuilder.bind(Emailqueue()).to(fanoutExchange());
    }
    @Bean
    public Binding duanxinBinding(){
        return BindingBuilder.bind(duanxinqueue()).to(fanoutExchange());
    }
}
